﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tools.DA.Repository;

namespace Tools.DA
{
    public class AppDABase<TContext>
        where TContext : ContextBase, new()
    {
        //private static IDictionary<Type, object> _UnitOfWorkList = new Dictionary<Type, object>();

        //public static IUnitOfWork GetUnitOfWork<TContext>()
        //    where TContext : ContextBase, new()
        //{
        //    var type = typeof(TContext);
        //    if (!_UnitOfWorkList.ContainsKey(type))
        //        _UnitOfWorkList.Add(type, new UnitOfWork<TContext>());
        //    return (IUnitOfWork)_UnitOfWorkList[type];
        //}

        private static IUnitOfWork _UnitOfWork;

        public static IUnitOfWork GetUnitOfWork()
        {
            if (_UnitOfWork == null)
                _UnitOfWork = new UnitOfWork<TContext>();
            return _UnitOfWork;
        }

    }
}
